package demo.reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class Test {
	public static void main(String[] args) throws Exception {
		Class<?> c = Class.forName("reflect.Person");
		Constructor<?> con = c.getConstructor(String.class, Integer.class);
		Person p = (Person) con.newInstance("�����", 23);
		p.show();
		Field f1 = c.getDeclaredField("gender");
		f1.setAccessible(true);
		f1.set(p, "��");
		p.show();
		Method m1 = c.getMethod("show");
		m1.invoke(p);
		Method m2 = c.getDeclaredMethod("eat", String.class);
		m2.setAccessible(true);
		m2.invoke(p, "�׷�");
	}
}
